<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Cate extends Model
{
    protected $table = 'cate';

    public $fillable = ['agent_id', 'name', 'pic', 'order_num', 'status', 'is_home'];

    // 是否首页展示
    public static $isHomeLabels = [
        0 => '否',
        1 => '是',
    ];

    public static $statusLabels = [
        0 => '冻结',
        1 => '正常',
    ];

    /**
     * 获取某个公司的商品分类名字数组
     *
     * @param $agent_id
     * @param boolean $all_status 是否获取所有状态的分类
     * @return mixed
     */
    public static function getCateNames($agent_id, $all_status = false)
    {
        $model = self::where('agent_id', $agent_id);
        !$all_status && $model->where('status', 1);
        return $model->pluck('name', 'id')->toArray();
    }
}
